package win.bojack.redis_learning.boot.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/redis")
public class RedisTestController {
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @GetMapping
    public String testRedis() {
        redisTemplate.opsForValue().set("name123", "lucy321");
        Object name = redisTemplate.opsForValue().get("name123");
        return name == null ? "" : name.toString();
    }
}
